#include "../src/biTree/biTree.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

extern func_BiTree fBiTree;
//ABDH#K###E##CFI###G#J##

int main(int argc, const char *argv[])
{
    int ret = 0;
    BiTNode *tree = NULL;

    // 创建一个二叉树
    printf("请按照先序输入二叉树：");
    tree = fBiTree.create();

    if (tree != NULL)
    {
        printf("二叉树创建成功！\n");
    }
    else
    {
        printf("二叉树创建出现异常！\n");
        ret = -1;
        goto ERROR_END;
    }

    printf("先序遍历输出：");
    fBiTree.prevOrder(tree);
    putchar(10);

    printf("中序遍历输出：");
    fBiTree.inOrder(tree);
    putchar(10);

    printf("后序遍历输出：");
    fBiTree.postOrder(tree);
    putchar(10);

    printf("层序遍历输出：");
    fBiTree.levelOrder(tree);
    putchar(10);

ERROR_END:
    // 释放二叉树
    fBiTree.release(tree);

    printf("system exit!\n");

    return ret;
}
